package com.lizhi.menu.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lizhi.menu.Dto.InvitationDto;
import com.lizhi.menu.domain.Invitation;
import com.lizhi.menu.mapper.InvitationMapper;
import com.lizhi.menu.service.IInvitationService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 帖子Service业务层处理
 *
 * @author lizhi
 * @date 2023-05-18
 */
@Service
@RequiredArgsConstructor
public class InvitationServiceImpl implements IInvitationService {
    private final InvitationMapper invitationMapper;

    /**
     * 查询帖子
     *
     * @param id 帖子主键
     * @return 帖子
     */
    @Override
    public Invitation selectInvitationById(String id) {
        return invitationMapper.selectById(id);
    }

    /**
     * 查询帖子列表
     *
     * @param invitation 帖子
     * @return 帖子
     */
    @Override
    public Page<Invitation> selectInvitationList(InvitationDto invitation) {
        return invitationMapper.selectInvitationList(invitation.createPage(),invitation);
    }

    /**
     * 新增帖子
     *
     * @param invitation 帖子
     * @return 结果
     */
    @Override
    public int insertInvitation(Invitation invitation) {
        invitation.setCreateTime(LocalDateTime.now());
        return invitationMapper.insertInvitation(invitation);
    }

    /**
     * 修改帖子
     *
     * @param invitation 帖子
     * @return 结果
     */
    @Override
    public int updateInvitation(Invitation invitation) {
        invitation.setUpdateTime(LocalDateTime.now());
        return invitationMapper.updateInvitation(invitation);
    }

    /**
     * 批量删除帖子
     *
     * @param ids 需要删除的帖子主键
     * @return 结果
     */
    @Override
    public int deleteInvitationByIds(List<String> ids) {
        return invitationMapper.deleteInvitationByIds(ids);
    }

    /**
     * 删除帖子信息
     *
     * @param id 帖子主键
     * @return 结果
     */
    @Override
    public int remove(String id) {
        return invitationMapper.deleteInvitationById(id);
    }
}
